package com.hspedu.newData.dmsxl.数组.双指针;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-22 
 * @Version: 1.0
 */

public class LC283移动零 {

    public void moveZeroes(int[] nums) {

        int slow = 0;
        int fast = 0;

        while (fast < nums.length){
            if (nums[fast] != 0){
                nums[slow++] = nums[fast];
            }
            fast++;
        }
        while (slow < fast){
            nums[slow++] = 0;
        }
    }

    @Test
    public void test(){
        int[] nums = new int[]{0,1,0,3,12};
        moveZeroes(nums);
        System.out.println("=======");
    }
}
